<style lang="less">
    @import "detail.less";
</style>
<template>


    <div>
        <Card style="width:100%" shadow>
            <!--基本信息-->
            <Row>
                <Alert>
                    <h2>基本信息</h2>
                </Alert>
                <Form ref="baseInfo" :model="caseInfo" class="detailForm"
                      :label-width="100"
                      inline>
                    <Row>
                        <Col span="6">
                            <FormItem prop="startTime" label="申请时间">
                                <DatePicker type="date" v-model="caseInfo.startTime" disabled placeholder="选择日期"></DatePicker>
                            </FormItem>
                        </Col>
                        <Col span="6">
                            <FormItem prop="endTime" label="结束时间" >
                                <DatePicker type="date" v-model="caseInfo.endTime" disabled placeholder="选择日期"></DatePicker>
                            </FormItem>
                        </Col>
                        <Col span="6">
                            <FormItem prop="createBy" label="创建人">
                                <Input type="text" v-model="caseInfo.createBy" disabled placeholder="请输入">
                                </Input>
                            </FormItem>
                        </Col>
                    </Row>
                </Form>
            </Row>
            <!--合同信息-->
            <Row>
                <Form ref="contractInfo" :model="contractInfo" class="detailForm"
                      :label-width="100"
                      inline>
                    <Alert>
                        <h2>合同信息</h2>
                    </Alert>
                    <Row>
                        <Col span="6">
                            <FormItem prop="applyNo" label="申请编号" >
                                <Input type="text" v-model="contractInfo.applyNo" disabled placeholder="请输入">
                                </Input>
                            </FormItem>
                        </Col>
                        <Col span="6">
                            <FormItem prop="custName" label="客户姓名" >
                                <Input type="text" v-model="contractInfo.custName" disabled placeholder="请输入">
                                </Input>
                            </FormItem>
                        </Col>
                        <Col span="6">
                            <FormItem prop="certNo" label="证件号码" >
                                <Input type="text" v-model="contractInfo.certNo" disabled placeholder="请输入">
                                </Input>
                            </FormItem>
                        </Col>
                        <Col span="6">
                            <FormItem prop="phone" label="联系方式" >
                                <Input type="text" v-model="contractInfo.phone" disabled placeholder="请输入">
                                </Input>
                            </FormItem>
                        </Col>
                    </Row>
                    <Row>
                        <Col span="6">
                            <FormItem prop="startDate" label="合同激活时间" >
                                <DatePicker type="date" v-model="contractInfo.startDate" disabled placeholder="选择日期"></DatePicker>
                            </FormItem>
                        </Col>
                        <Col span="6">
                            <FormItem prop="endDate" label="合同终止时间" >
                                <DatePicker type="date" v-model="contractInfo.endDate" disabled placeholder="选择日期"></DatePicker>
                            </FormItem>
                        </Col>
                    </Row>
                </Form>
            </Row>
            <!--业务办理-->
            <Row>
                <Alert>
                    <h2>业务办理</h2>
                </Alert>
                <Form ref="caseInfo" :model="caseInfo" :rules="caseInfoFormValidate" class="detailForm"
                      :label-width="100"
                      inline>
                    <Row>
                        <Col span="6">
                            <FormItem prop="receivingBank" label="收款银行">
                                <Select v-model="caseInfo.receivingBank" placeholder="请选择">
                                    <Option
                                            v-for="(item,index) in dataDict.bankCode"
                                            :key="index"
                                            :value="item.value"
                                    >{{item.title}}</Option>
                                </Select>
                            </FormItem>
                        </Col>
                        <Col span="6">
                            <FormItem prop="payAmt" label="打款金额" >
                                <Input type="text" v-model="caseInfo.payAmt" placeholder="请输入">
                                </Input>
                            </FormItem>
                        </Col>
                        <Col span="6">
                            <FormItem prop="payTime" label="打款时间">
                                <DatePicker type="date" v-model="caseInfo.payTime" :options="dateLimit" :start-date="dateFocus" placeholder="选择日期"></DatePicker>
                            </FormItem>
                        </Col>
                        <Col span="6">
                            <FormItem prop="payer" label="打款人" >
                                <Input type="text" v-model="caseInfo.payer" placeholder="请输入">
                                </Input>
                            </FormItem>
                        </Col>
                    </Row>
                    <Row>
                        <Col span="24">
                            <FormItem prop="remarks" label="说明">
                                <Input type="text" class="holeLine" v-model="caseInfo.remarks" placeholder="请输入">
                                </Input>
                            </FormItem>
                        </Col>
                    </Row>
                    <Row>
                        <Col span="24">
                            <FormItem prop="images" label="打款凭证">
                                <div class="imageArea"></div>
                            </FormItem>
                        </Col>
                    </Row>
                    <Col align="middle">
                        <Form-item>
                            <Button @click="agreeHandle" type="primary" icon="md-bookmark">保存</Button>
                            <Button @click="refuseHandle" type="primary" icon="md-send">提交</Button>
                        </Form-item>
                    </Col>
                </Form>
            </Row>
        </Card>
    </div>
</template>

<script>
    import {
        getByTypes
    } from "_p/basic/api/admin/datadic";
    import {
        queryCorporateByCaseNo,
        saveCorporate,
        submitCorporate,
        contractInfoForCorporate
    } from "@/projects/afs-apply/api/contract/corporate/corporateTransferManagement";

    export default {
        name: "detailForChannelEdit",
        components: {
        },
        props: {
            obj: {
                caseNo: "",
                contractNo: "",
                id:"",
                caseType:"",
                type:Object
            }
        },
        data: function () {
            return {
                dateLimit:{
                    disabledDate (date) {
                        return date && date.valueOf() > Date.now();
                    }
                },
                dateFocus: new Date(),
                dicKeys: [
                    "bankCode"
                ],
                dataDict:{},
                caseInfo:{},
                caseInfoFormValidate:{},
                contractInfo:{},
                contractInfoFormValidate:{},
                productInfo:{},
                bankArriveColums:[
                    {title: "网银编号",key: "ebankNo",minWidth: 160,align: "center"},
                    {title: "到账时间",key: "arrivalTime",minWidth: 100,align: "center"},
                    {title: "到账银行",key: "receivingBank",minWidth: 150,align: "center",slot: "receivingBank"},
                    {title: "到账银行账户",key: "bankAccount",minWidth: 150,align: "center"},
                    {title: "付款客户",key: "paymentCust",minWidth: 100,align: "center"},
                    {title: "客户账号",key: "custAccount",minWidth: 150,align: "center"},
                    {title: "到账金额",key: "receivedAmt",minWidth: 100,align: "center"},
                    {title: "摘要",key: "summary",minWidth: 150,align: "center"},
                ],
                bankArriveList:[],
            }
        },
        methods: {
            agreeHandle(){
                this.$Spin.show();
                //数据组装
                this.caseInfo.contractNo = this.contractInfo.contractNo;
                this.caseInfo.custName = this.contractInfo.custName;
                this.caseInfo.certNo = this.contractInfo.certNo;
                this.caseInfo.phone = this.contractInfo.phone;
                this.caseInfo.createTagStr = this.userInfo.userRealName + " " +this.userInfo.phone;
                //逾期天数
                this.caseInfo.overdueDays = this.contractInfo.overdueDaysHis;
                saveCorporate(this.caseInfo).then(res => {
                    if (res.code === "0000") {
                        this.caseInfo = res.data;
                        this.$Message.success("保存成功");
                    }
                    this.$Spin.hide();
                }).catch(e => {
                    this.$Spin.hide();
                });
            },
            refuseHandle(){
                this.$Spin.show();
                //数据组装
                this.caseInfo.contractNo = this.contractInfo.contractNo;
                this.caseInfo.custName = this.contractInfo.custName;
                this.caseInfo.certNo = this.contractInfo.certNo;
                this.caseInfo.phone = this.contractInfo.phone;
                this.caseInfo.createTagStr = this.userInfo.userRealName + " " +this.userInfo.phone;
                //逾期天数
                this.caseInfo.overdueDays = this.contractInfo.overdueDaysHis;
                submitCorporate(this.caseInfo).then(res => {
                    this.$Spin.hide();
                    if (res.code === "0000") {
                        this.$Message.success("提交成功");
                        setTimeout(() => {
                            this.$emit('afterHandle');
                        }, 1000);
                    }
                }).catch(e => {
                    this.$Spin.hide();
                    return false;
                });

            },
            initDataDic(){
                let self = this;
                getByTypes(this.dicKeys).then(res => {
                    if (res.code === "0000" && res.data) {
                        self.dataDict = res.data;
                    }
                });
            },
            queryCaseInfo(){

                queryCorporateByCaseNo(this.obj.caseNo).then(res => {
                    if (res.code === "0000") {
                        this.caseInfo = res.data;
                        if (!this.caseInfo.caseSource || this.caseInfo.caseSource === ""){
                            this.caseInfo.caseSource = "SP";
                        }
                        if (!this.caseInfo.caseType || this.caseInfo.caseType === ""){
                            this.caseInfo.caseType = this.obj.caseType;
                        }
                    }
                });
            },
            queryContractInfo(){
                contractInfoForCorporate(this.obj.contractNo).then(res => {
                    if (res.code === "0000") {
                        this.contractInfo = res.data;
                    }
                });
            },
            init(){
                //加载数字字典
                this.initDataDic();
                //加载合同信息
                this.queryContractInfo();
                //加载对公结算案件详情
                this.queryCaseInfo();
            },
        }
    }
</script>

<style scoped>

</style>
